<!DOCTYPE HTML>
<html  lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-tChannel-edit" th:object="${tChannel}">
            <input id="channelId" name="channelId" th:field="*{channelId}"  type="hidden">

			<div class="form-group">	
				<label class="col-sm-3 control-label">名称：</label>
				<div class="col-sm-8">
					<input id="name" name="name" th:field="*{name}" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">Appid：</label>
				<div class="col-sm-8">
					<input id="appId" name="appId" th:field="*{appId}" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">缩略图：</label>
				<div class="col-sm-8">
					<input id="iconPath" name="iconPath" th:field="*{iconPath}" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">二维码图：</label>
				<div class="col-sm-8">
					<input id="qrcodePath" name="qrcodePath" th:field="*{qrcodePath}" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">对方路径：</label>
				<div class="col-sm-8">
					<input id="pagePath" name="pagePath" th:field="*{pagePath}" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">我方路径：</label>
				<div class="col-sm-8">
					<input id="mePagePath" name="mePagePath" th:field="*{mePagePath}" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">描述：</label>
				<div class="col-sm-8">
					<input id="descr" name="descr" th:field="*{descr}" class="form-control" type="text">
				</div>
			</div>
			<!--<div class="form-group">
				<label class="col-sm-3 control-label">帐号状态（0正常 1停用）：</label>
				<div class="col-sm-8">
					<input id="status" name="status" th:field="*{status}" class="form-control" type="text">
				</div>
			</div>-->
			<div class="form-group">
				<label class="col-sm-3 control-label">状态：</label>
				<div class="col-sm-8">
					<div class="onoffswitch">
						<input type="checkbox" th:checked="${tChannel.status == '0' ? true : false}" class="onoffswitch-checkbox" id="status" name="status">
						<label class="onoffswitch-label" for="status">
							<span class="onoffswitch-inner"></span>
							<span class="onoffswitch-switch"></span>
						</label>
					</div>
				</div>
			</div>
		</form>
    </div>
    <div th:include="include::footer"></div>
    <script type="text/javascript">
		var prefix = ctx + "treasure/tChannel";
		$("#form-tChannel-edit").validate({
			rules:{
				xxxx:{
					required:true,
				},
			}
		});
		
		function submitHandler() {
	        if ($.validate.form()) {
	            //$.operate.save(prefix + "/edit", $('#form-tChannel-edit').serialize());
                edit();
	        }
	    }

        function edit() {
		    var channelId = $("input[name='channelId']").val();
            var name = $("input[name='name']").val();
            var appId = $("input[name='appId']").val();
            var iconPath = $("input[name='iconPath']").val();
            var qrcodePath = $("input[name='qrcodePath']").val();
            var pagePath = $("input[name='pagePath']").val();
            var mePagePath = $("input[name='mePagePath']").val();
            var descr = $("input[name='descr']").val();
            var status = $("input[name='status']").is(':checked') == true ? 0 : 1;
            $.ajax({
                cache : true,
                type : "POST",
                url : prefix + "/edit",
                data : {
                    "channelId":channelId,
                    "name": name,
                    "appId":appId,
                    "iconPath":iconPath,
                    "qrcodePath":qrcodePath,
                    "pagePath":pagePath,
                    "mePagePath":mePagePath,
                    "descr":descr,
                    "status": status
                },
                async : false,
                error : function(request) {
                    $.modal.alertError("系统错误");
                },
                success : function(data) {
                    $.operate.successCallback(data);
                }
            });
        }
	</script>
</body>
</html>
